Part Number Hot Search : 
SR5SA54 TDA8944 2SK2043 FED16DT TC9106 AGB3303 2N60C CSNR161
Product Description
Full Text Search
 

To Download AN74 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  application note 1 of 9 www.xicor.com june, 2000 AN74 software creates compatible 64kbit 2-wire serial eeproms by applications staff introduction in recent years, nonvolatile memory manufacturers have pushed the envelope on serial eeprom performance. devices now exist with higher densities, extra data protection features, and lower operating voltages, while at the same time consuming less power. in many appli- cations, these newer generation devices are ideal because they satisfy important system requirements. among these devices, 64kbit 2-wire serial eeproms in 8-lead soic packages have been particularly well received. unfortunately, not all manufacturers have implemented a common set of features within their devices. this causes problems for a designer who desires multiple sources. although none of these devices could ever be considered as second sources for one another, there are some steps that can be taken by a designer to guarantee that any of these 64kbit devices can be used interchangeably in a system. in this note, well consider devices from xicor (x24645), atmel (at24c64), and microchip (24c65). for the addressing of the x24645, xicor has implemented an approach that differs slightly from the more conventional addressing scheme found on lower density 2-wire devices (e.g. x24c02). the advantage is a simpli?ation of the protocol for accessing the x24645. the at24c64 and 24c65 adhere to the older standard, however in systems attempting to use multiple sources for 64kbit devices, certain software modi?ations and pin connections could be made to ensure compatibility. in this note, the details of this implementation are explained and general purpose c code provided. the code was debugged using turbo c and fig. 3 shows the simple test set-up. nc s1 s2 v ss a0 a1 a2 v ss a0 a1 a2 gnd v cc wp scl sda v cc nc scl sda v cc wp scl sda pin descriptions scl serial clock sda serial data s1 device select input s2 device select input wp write protect nc no connect v cc supply v ss ground pin descriptions scl serial clock sda serial data a0-a2 chip select inputs nc no connect v cc supply v ss ground pin descriptions scl serial clock sda serial data a0-a2 address inputs wp write protect v cc supply gnd ground x24645 24c65 at24c64 dip/soic dip/soic dip/soic
2 of 9 AN74 application note www.xicor.com june, 2000 slave address the rst discrepancy encountered between xicor s x24645 and the microchip 24c65 or atmel at24c64 is the difference in slave addressing and the protocol for sending upper address bits to the device. both the 24c65 and at24c64 use an 8-bit slave address consisting of the device id (1010), a 3-bit device address (a2,a1,a0), and the r/w bit. the 13-bit array address is transferred following the slave address by sending two additional bytes, containing 3 zeroes (000) or 3 don t cares (xxx) and the complete address. this sequence is similar to lower density devices available from all three manufacturers. xicor s x24645 has a slave address and upper array address protocol consisting of an 8-bit slave address followed by a single address byte. the slave address consists of 2 device select bits (s2,s1), the 5 msbs of the array address (a12,a11,a10,a9,a8), and the r/w bit. this allows for a 1-byte simpli cation of the software overhead when the x24645 is accessed. in order to make these 3 devices functional in the same socket, pins 1, 2, and 3 must be tied to vss. on power- up, the master should transmit (10101110) as the slave address. if the xicor device is present, the master will receive an acknowledge. if the microchip or atmel devices are present, then there will not be an acknowl- edge. the software routine should then set a x24645 detected ag for later use. write protection register the x24645 contains an internal write protect register (wpr) that is used to control the state of the device. as soon as the x24645 is detected, a separate routine is used to correctly set the wpr. first the wel bit is set, then the rwel bit is set, and then the block protect (bp) and wpen registers are set. if the bp registers are set to protect the upper 1/2 of the array, then control of the array write protection for both the atmel and xicor devices will behave similarly, depending on the wp pin (pin 7). array write protection all three devices have write protection features, however guaranteeing compatibility with the microchip device is a problem. in order to protect the upper 1/2 of the array for the microchip part, a software sequence must be sent to the device. in order to implement this feature, we would have to assume that the wp input pin of the socket is being driven by a microcontroller, which could then also execute a special routine for the microchip device. if the at24c64 is actually present when this occurs, data corruption is possible unless the starting block for the microchip device is de ned with the b3 bit set (i.e. b3,b2,b1,b0 = 1xxx). additionally, with the 24c65, once the write protection mechanism is set, it cannot be undone. this is in contrast to the xicor and atmel devices which allow for write protection control by the wp pin. of special note is the scheme used on the x24645. by using a wpr with a write protect enable bit (wpen), a system can have the wp pin hard-wired high without the array being protected. during system test, the e2prom can be loaded with data and at this point, the wpen bit can be set, which would "lock" the array write protection. the only way to alter the write protection at that point is to take wp low and/or reset the wpen bit. because of the dif culties, write protec- tion on the microchip 24c65 has not been implemented in the attached code, though simple modi cations can be made to provide for it.
3 of 9 AN74 application note www.xicor.com june, 2000 serial eeprom modes of operation once software has detected the x24645, the necessary modi cations to the protocol are made automatically. for 2-wire serial eeproms, there are really only two modes of operation, with all others being special cases of these modes: page write and random sequential read. a single byte write operation is merely a special case of a page write operation, where only 1 data byte is sent to the device. likewise, a single byte read operation is a special case of the sequential read operations. because of the way that the random read protocol is imple- mented in the code, a current address read operation can be seen to be a random read operation without the dummy address write preceding it. note that the s t a r t s t o p a c k a c k a c k slave address word address (n) data (n) r/w data (n+31) s t a r t s t o p a c k a c k a c k slave address first w ord address (n) data (n) r/w a c k data (n+31) second w ord address (n) a c k a c k s t a r t s t o p a c k a c k a c k slave address word address 1 data (n) r/w a c k data (n+7) word address 0 a c k figure 1. page write (byte write) operations for each device figure 2. random sequential read (or current address sequential read) operations for each device. for a current address read operation, disregard the dummy write operation. s t a r t a c k a c k slave address word address (n) r/w s t a r t a c k a c k slave address first wordaddress (n) r/w second word address (n) s t a r t s t o p a c k slave address r/w dummy write operation a c k data (n) a c k data (n+x) s t a r t a c k a c k a c k slave address word address 1 d ata (n) r/w a c k data(n+x) word address 0 a c k s t o p a c k s t a r t slave address r/w dummy write operation a c k d ata (n) a c k data(n +x) a c k s t o p a c k s t a r t slave address r/w dummy write operation
4 of 9 AN74 application note www.xicor.com june, 2000 x24645 does not internally increment its address counter after the last byte written, which differs from the behavior of the at24c64 and 24c65. for example, write operations ending on the last byte of a page (e.g. $001f) followed by a current address read, will return data from different locations, depending on the device. for the x24645, data would be read from $001f. for the 24c65, it would be from $0018, but with the at24c64, it would be from $0000. this should be taken into account when using the current address sequential read operation. endurance another peculiarity with the microchip 24c65 device (as well as microchip's 24lc65 and 24aa65 lower voltage versions of the 24c65) is its endurance speci ca- tion. although microchip touts their eeproms as having more than a million cycles endurance on the 24c65, this only applies to a small portion of the memory array. a user de ned 4kbit block will provide 1,000,000 cycles, but the rest of the array is only speci- ed as 10,000 cycles. both xicor and atmel specify their devices at 100,000 cycles for every byte in the array. with microchip, an average endurance of 71,875 endurance cycles per byte is perhaps a more appropriate spec. in reality, few systems require such endurance and this code does not attempt to change the high endurance block position from the microchip default position. again, simple modi cations to the code are all that are required to implement this feature, if it is desirable to relocate this high endurance block. page size though xicor s x24645 and atmel s at24c64 have 32-byte pages, the microchip 24c65 only has an 8-byte page. to compensate for this aw, microchip uses a 64-byte fifo buffer internally to write consecutive pages. we can use this feature to make the microchip device compatible with 32-byte page devices, however there could be some problems with the 24c65 due to wrap-around within the fifo. careful use of the seq_write() routine will prevent anomalous behavior. never write more than 32 bytes on a page at a time and never attempt to utilize the wrap-around feature of the xicor and atmel devices when a microchip device could be present. that should be suf cient to avoid any problems. conclusion though all three devices have been tested and will work with this generic code, the xicor x24645 and atmel at24c64 clearly stand-out as the best design choices. the potential headaches associated with guaranteeing compatibility between the microchip 24c65 software protocols (i.e. setting the high endurance block or the array write protection) and the protocols of the other devices would prevent the use of some advanced features on the 24c65, possibly limiting its usefulness in a system. furthermore, the x24645 has some apparent advantages over the at24c64 because of its more ex- ible blocklock array write protection and the presence of the wpen bit in the wpr, which makes this device more attractive for programming during system production. 13 25 12 24 11 23 10 22 9 21 8 20 7 19 6 18 5 17 4 16 3 15 2 14 1 connect or db25 74ls07 scl sda vcc vcc figure 3: simple interface between 2-wire serial eeproms and a parallel printer port on a pc
5 of 9 AN74 application note www.xicor.com june, 2000 /*******************************************************************/ /* */ /* software for creating compatibility between xicor's x24645, */ /* atmel's at24c64, and microchip's 24c65 2-wire serial eeproms. */ /* this code contains all of the routines necessary for accessing */ /* these devices. simply use the seq_read() and seq_write() */ /* routines for access, regardless of which device is present. */ /* /* note that in this code, all attempts to read the status of the */ /* sda pin (by the pc) assume that the sda level is logically */ /* inverted, due to this particular test set-up (fig. 3). if this */ /* is not true for other hardware set-ups, then this code must be */ /* altered accordingly. */ /* ghc iv */ /*******************************************************************/ #include #include int data_port = 0x378; /* printer port output address*/ int status_port = 0x379; /* printer port input address*/ unsigned char control = 0xff; unsigned char xicor_flag; /* x24645 detected flag */ void scl_high(){ control = control | 0x04; /* set scl bit at port */ outportb(data_port, control); } void scl_low(){ control = control & 0xfb; /* reset scl bit at port */ outportb(data_port, control); } void sda_high(){ control = control | 0x02; /* set sda bit at port */ outportb(data_port,control); } void sda_low(){ control = control & 0xfd; /* reset sda bit at port */ outportb(data_port,control); } void start(){ sda_high(); scl_high(); sda_low(); scl_low(); } void stop(){ sda_low(); scl_high(); sda_high(); }
6 of 9 AN74 application note www.xicor.com june, 2000 unsigned char clock(){ unsigned char sda_value; scl_high(); sda_value = inportb(status_port); /* read port */ sda_value = sda_value & 0x80; /* isolate sda */ scl_low(); sda_value = sda_value >> 7; /* shift to lsb */ return(sda_value); /* and return data */ } void ack(){ sda_low(); clock(); /* master sends acknowledge */ } void nack(){ sda_high(); /* master receives acknowledge */ clock(); } void out_byte(unsigned char byte){ char count; for (count = 0; count <= 7; count++){ /* send data to eeprom */ if ((byte & 0x80) == 0) /* one bit at a time */ sda_low(); else sda_high(); byte = byte << 1; /* shift for next bit */ clock(); } } unsigned char get_byte(){ int count; unsigned char byte,temp; byte = 0; for (count = 0; count <= 7; count++){ /* read data from eeprom */ byte = byte << 1; /* one bit at a time */ sda_high(); temp = clock(); /* input bit from port */ if (temp == 0) byte = byte | 0x01; } return(byte); /* return data byte */ } unsigned char serial_detect(){ unsigned char temp; start(); out_byte(0xae); /* send slave address */ sda_high();
7 of 9 AN74 application note www.xicor.com june, 2000 temp = clock(); /* check for acknowledge */ stop(); return(temp); } void ack_poll(){ unsigned char poll; do { /* ack polling loop */ start(); if (xicor_flag == 1) out_byte(0x80); /* xicor slave address */ else out_byte(0xa0); /* microchip and atmel slave address */ sda_high(); poll = clock(); /* check for acknowledge */ } while (poll == 0); stop(); } void program_wpr(){ start(); out_byte(0xbe); /* x24645 slave address for location $1fff */ nack(); out_byte(0xff); nack(); out_byte(0x02); /* set wel bit */ nack(); stop(); start(); out_byte(0xbe); nack(); out_byte(0xff); nack(); out_byte(0x06); /* set rwel bit */ nack(); stop(); start(); out_byte(0xbe); nack(); out_byte(0xff); nack(); out_byte(0x92); /* set wpen, bp1, and bp0 bits */ nack(); stop(); ack_poll(); } void dummy_write(int addr){ int temp; if (xicor_flag == 1){ temp = (((addr >> 7) & 0x3e) | 0x80); /* construct x24645 */ /* slave address */ start();
8 of 9 AN74 application note www.xicor.com june, 2000 out_byte(temp); nack(); temp = (addr & 0xff); /* construct x24645 address byte */ out_byte(temp); nack(); } else{ start(); out_byte(0xa0); /* microchip and atmel slave address */ nack(); temp = ((addr & 0xff00) >> 16); /* construct first address byte */ out_byte(temp); nack(); temp = addr & 0xff; /* construct second address byte */ out_byte(temp); nack(); } } /********************************************************************/ /* */ /* sequential read routine that handles all read operations. for */ /* current address reads, set current != 0 and addr as a don't care */ /* when calling the routine, otherwise addr = starting address and */ /* *bytes points to buffer where data is to be stored for later */ /* use. no_bytes is the number of bytes to be sequentially read */ /* from the eeprom. */ /* */ /********************************************************************/ void seq_read(int current,int no_bytes,int addr,unsigned char *bytes){ int n, temp; if (current == 0) /* random read? */ dummy_write(addr); /* yes, send address */ if (xicor_flag == 1){ /* is it the x24645? */ start(); /* yes */ temp = (((addr >> 7) & 0x3e) | 0x81); /* construct slave address */ out_byte(temp); nack(); } else{ start(); /* no */ out_byte(0xa1); /* slave address for atmel and microchip */ nack(); } for (n = 0;n < no_bytes - 1; n++){ /* sequentially read data */ bytes[n] = get_byte(); /* in loop and send acknowledges */ ack(); } bytes[no_bytes - 1] = get_byte(); /* for last databyte, don't */ stop(); /* send acknowledge */ }
9 of 9 AN74 application note www.xicor.com june, 2000 /*******************************************************************/ /* */ /* sequential write routine handles all write operations. no_bytes */ /* is number of bytes to write, starting at address (addr), and */ /* take the data from the buffer pointed to by *bytes. */ /* */ /*******************************************************************/ void seq_write(int no_bytes,int addr,unsigned char *bytes){ unsigned char temp; int n; dummy_write(addr); /* send address to eeprom */ for (n = 0;n < no_bytes; n++){ out_byte(bytes[n]); /* loop and send data bytes */ nack(); } stop(); /* begin nonvolatile write cycle */ ack_poll(); /* poll for cycle completion */ } /******************************************************/ /* */ /* simple program to demonstrate these routines. */ /* */ /******************************************************/ main(){ unsigned char data1[]={31,32,33,34,35}; /* buffer of data bytes */ unsigned char data2[]={41,42,43,44,45}; /* buffer of data bytes */ unsigned char data3[512]; /* buffer to store bytes from eeprom */ unsigned char data4[512]; /* buffer to store bytes from eeprom */ xicor_flag=serial_detect(); /* check for x24645 */ if (xicor_flag==1) /* is it x24645? */ program_wpr(); /* yes, set up wpr */ seq_write(5,59,&data1); /* page write ending on last byte of page */ seq_write(5,64,&data2); /* page write beginning on 1st byte of next page */ seq_read(0,6,59,&data3); /* random read across page boundaries (6 bytes) */ seq_read(1,4,0,&data4); /* current address read of remaining 4 bytes */ }


▲Up To Search▲   

 
Price & Availability of AN74

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X